package com.sync.data.mce.repository;


import com.sync.data.ievent.entity.Hcp;
import com.sync.data.mce.entity.MdmSpeaker;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * 讲者专用字段 sxh
 */
@Repository
public interface MdmSpeakerRepository extends JpaRepository<MdmSpeaker, String>, JpaSpecificationExecutor<MdmSpeaker> {

    MdmSpeaker findEntityByHcpId(String hcpId);


    /**
     * 更新讲者评级
     * @param paidTiers
     * @param id
     */
    @Transactional
    @Modifying
    @Query("update MdmSpeaker u set u.paidTiers =:paidTiers where u.id = :id  ")
    void updateSpeackerGradeById(String paidTiers, String id);

    /**
     * 更新讲者课题、标签
     * @param speakerSubjects
     * @param speakerLabel
     * @param id
     */
    @Transactional
    @Modifying
    @Query("update MdmSpeaker u set u.speakerSubjects =:speakerSubjects,u.speakerLabel=:speakerLabel where u.id = :id  ")
    void updateSpeakerTopicTagsById(String speakerSubjects,String speakerLabel, String id);
}
